

ALTER TABLE CIU.CIUACADEMICPERIODS
 DROP PRIMARY KEY CASCADE;

DROP TABLE CIU.CIUACADEMICPERIODS CASCADE CONSTRAINTS;

CREATE TABLE CIU.CIUACADEMICPERIODS
(
  ID                        NUMBER              NOT NULL,
  NAME                      VARCHAR2(128 BYTE),
  START_DATE                DATE,
  END_DATE                  DATE,
  PREREGISTRATION_START     DATE,
  PREREGISTRATION_END       DATE,
  REGISTRATION_START        DATE,
  REGISTRATION_END          DATE,
  CLASSES_START             DATE,
  CLASSES_END               DATE,
  SCORE_REGISTRATION_START  DATE,
  SCORE_REGISTRATION_END    DATE,
  SCORE_PUBLICATION         DATE,
  COURSES_PUBLICATION       DATE,
  ISACTIVE                  VARCHAR2(1 BYTE)
)
TABLESPACE USERS
RESULT_CACHE (MODE DEFAULT)
PCTUSED    0
PCTFREE    10
INITRANS   1
MAXTRANS   255
STORAGE    (
            INITIAL          64K
            NEXT             1M
            MAXSIZE          UNLIMITED
            MINEXTENTS       1
            MAXEXTENTS       UNLIMITED
            PCTINCREASE      0
            BUFFER_POOL      DEFAULT
            FLASH_CACHE      DEFAULT
            CELL_FLASH_CACHE DEFAULT
           )
LOGGING 
NOCOMPRESS 
NOCACHE
NOPARALLEL
MONITORING;


CREATE UNIQUE INDEX CIU.CIUACADEMICPERIODS_PK ON CIU.CIUACADEMICPERIODS
(ID)
LOGGING
TABLESPACE USERS
PCTFREE    10
INITRANS   2
MAXTRANS   255
STORAGE    (
            INITIAL          64K
            NEXT             1M
            MAXSIZE          UNLIMITED
            MINEXTENTS       1
            MAXEXTENTS       UNLIMITED
            PCTINCREASE      0
            BUFFER_POOL      DEFAULT
            FLASH_CACHE      DEFAULT
            CELL_FLASH_CACHE DEFAULT
           )
NOPARALLEL;


CREATE OR REPLACE TRIGGER CIU.ACADEMICPERIOD_ID_TRIGGER
before insert ON CIU.CIUACADEMICPERIODS for each row
begin
     select ACADEMICPERIOD_ID_SEQ.nextval into :new.id from dual;
end;
/


ALTER TABLE CIU.CIUACADEMICPERIODS ADD (
  CONSTRAINT CIUACADEMICPERIODS_PK
  PRIMARY KEY
  (ID)
  USING INDEX CIU.CIUACADEMICPERIODS_PK
  ENABLE VALIDATE);

  
 ---
 
 ALTER TABLE CIU.CIUCONTRACTS
 DROP PRIMARY KEY CASCADE;

DROP TABLE CIU.CIUCONTRACTS CASCADE CONSTRAINTS;

CREATE TABLE CIU.CIUCONTRACTS
(
  ID               NUMBER,
  CONTRACT_NUMBER  VARCHAR2(16 BYTE),
  CIUUSER_ID       NUMBER,
  CONTRACT_VALUE   NUMBER,
  START_DATE       DATE,
  END_DATE         DATE,
  HOURS            NUMBER
)
TABLESPACE USERS
RESULT_CACHE (MODE DEFAULT)
PCTUSED    0
PCTFREE    10
INITRANS   1
MAXTRANS   255
STORAGE    (
            INITIAL          64K
            NEXT             1M
            MAXSIZE          UNLIMITED
            MINEXTENTS       1
            MAXEXTENTS       UNLIMITED
            PCTINCREASE      0
            BUFFER_POOL      DEFAULT
            FLASH_CACHE      DEFAULT
            CELL_FLASH_CACHE DEFAULT
           )
LOGGING 
NOCOMPRESS 
NOCACHE
NOPARALLEL
MONITORING;


CREATE UNIQUE INDEX CIU.CIUCONTRACTS_PK ON CIU.CIUCONTRACTS
(ID)
LOGGING
TABLESPACE USERS
PCTFREE    10
INITRANS   2
MAXTRANS   255
STORAGE    (
            INITIAL          64K
            NEXT             1M
            MAXSIZE          UNLIMITED
            MINEXTENTS       1
            MAXEXTENTS       UNLIMITED
            PCTINCREASE      0
            BUFFER_POOL      DEFAULT
            FLASH_CACHE      DEFAULT
            CELL_FLASH_CACHE DEFAULT
           )
NOPARALLEL;


CREATE OR REPLACE TRIGGER CIU.CONTRACT_ID_TRIGGER
before insert ON CIU.CIUCONTRACTS for each row
begin
     select CONTRACT_ID_SEQ.nextval into :new.id from dual;
end;
/


ALTER TABLE CIU.CIUCONTRACTS ADD (
  CONSTRAINT CIUCONTRACTS_PK
  PRIMARY KEY
  (ID)
  USING INDEX CIU.CIUCONTRACTS_PK
  ENABLE VALIDATE);

ALTER TABLE CIU.CIUCONTRACTS ADD (
  CONSTRAINT FK_CONTRACT_TEACHER 
  FOREIGN KEY (CIUUSER_ID) 
  REFERENCES CIU.CIUUSERS (ID)
  ENABLE VALIDATE);

  
  
  ---
  
ALTER TABLE CIU.CIUCOURSE_CIUSTUDENTS
 DROP PRIMARY KEY CASCADE;

DROP TABLE CIU.CIUCOURSE_CIUSTUDENTS CASCADE CONSTRAINTS;

CREATE TABLE CIU.CIUCOURSE_CIUSTUDENTS
(
  ID            NUMBER                          NOT NULL,
  CIUCOURSE_ID  NUMBER,
  CIUUSER_ID    NUMBER,
  SCORE1        INTEGER,
  SCORE2        INTEGER,
  SCORE3        INTEGER,
  TOTAL_SCORE   INTEGER
)
TABLESPACE USERS
RESULT_CACHE (MODE DEFAULT)
PCTUSED    0
PCTFREE    10
INITRANS   1
MAXTRANS   255
STORAGE    (
            INITIAL          64K
            NEXT             1M
            MAXSIZE          UNLIMITED
            MINEXTENTS       1
            MAXEXTENTS       UNLIMITED
            PCTINCREASE      0
            BUFFER_POOL      DEFAULT
            FLASH_CACHE      DEFAULT
            CELL_FLASH_CACHE DEFAULT
           )
LOGGING 
NOCOMPRESS 
NOCACHE
NOPARALLEL
MONITORING;


CREATE UNIQUE INDEX CIU.CIUCOURSE_CIUSTUDENTS_PK ON CIU.CIUCOURSE_CIUSTUDENTS
(ID)
LOGGING
TABLESPACE USERS
PCTFREE    10
INITRANS   2
MAXTRANS   255
STORAGE    (
            INITIAL          64K
            NEXT             1M
            MAXSIZE          UNLIMITED
            MINEXTENTS       1
            MAXEXTENTS       UNLIMITED
            PCTINCREASE      0
            BUFFER_POOL      DEFAULT
            FLASH_CACHE      DEFAULT
            CELL_FLASH_CACHE DEFAULT
           )
NOPARALLEL;


CREATE OR REPLACE TRIGGER CIU.COURSE_STUDENTS_ID_TRIGGER
before insert ON CIU.CIUCOURSE_CIUSTUDENTS for each row
begin
     select COURSE_STUDENTS_ID_SEQ.nextval into :new.id from dual;
end;
/


ALTER TABLE CIU.CIUCOURSE_CIUSTUDENTS ADD (
  CONSTRAINT CIUCOURSE_CIUSTUDENTS_PK
  PRIMARY KEY
  (ID)
  USING INDEX CIU.CIUCOURSE_CIUSTUDENTS_PK
  ENABLE VALIDATE);

ALTER TABLE CIU.CIUCOURSE_CIUSTUDENTS ADD (
  CONSTRAINT FK_DETAIL_COURSE 
  FOREIGN KEY (CIUCOURSE_ID) 
  REFERENCES CIU.CIUCOURSES (ID)
  ENABLE VALIDATE,
  CONSTRAINT FK_DETAIL_USER 
  FOREIGN KEY (CIUUSER_ID) 
  REFERENCES CIU.CIUUSERS (ID)
  ENABLE VALIDATE);

---

ALTER TABLE CIU.CIUCOURSES
 DROP PRIMARY KEY CASCADE;

DROP TABLE CIU.CIUCOURSES CASCADE CONSTRAINTS;

CREATE TABLE CIU.CIUCOURSES
(
  ID                    NUMBER                  NOT NULL,
  CIULANGUAGE_ID        NUMBER,
  CIULEVEL_ID           NUMBER,
  CIUTIMETABLE_ID       NUMBER,
  CIUROOM_ID            NUMBER,
  CIUUSER_ID            NUMBER,
  CIUCOURSESTATE_ID     NUMBER,
  CIUACADEMICPERIOD_ID  NUMBER
)
TABLESPACE USERS
RESULT_CACHE (MODE DEFAULT)
PCTUSED    0
PCTFREE    10
INITRANS   1
MAXTRANS   255
STORAGE    (
            INITIAL          64K
            NEXT             1M
            MAXSIZE          UNLIMITED
            MINEXTENTS       1
            MAXEXTENTS       UNLIMITED
            PCTINCREASE      0
            BUFFER_POOL      DEFAULT
            FLASH_CACHE      DEFAULT
            CELL_FLASH_CACHE DEFAULT
           )
LOGGING 
NOCOMPRESS 
NOCACHE
NOPARALLEL
MONITORING;


CREATE UNIQUE INDEX CIU.CIUCOURSES_PK ON CIU.CIUCOURSES
(ID)
LOGGING
TABLESPACE USERS
PCTFREE    10
INITRANS   2
MAXTRANS   255
STORAGE    (
            INITIAL          64K
            NEXT             1M
            MAXSIZE          UNLIMITED
            MINEXTENTS       1
            MAXEXTENTS       UNLIMITED
            PCTINCREASE      0
            BUFFER_POOL      DEFAULT
            FLASH_CACHE      DEFAULT
            CELL_FLASH_CACHE DEFAULT
           )
NOPARALLEL;


CREATE OR REPLACE TRIGGER CIU.COURSE_ID_TRIGGER
before insert ON CIU.CIUCOURSES for each row
begin
     select COURSE_ID_SEQ.nextval into :new.id from dual;
end;
/


ALTER TABLE CIU.CIUCOURSES ADD (
  CONSTRAINT CIUCOURSES_PK
  PRIMARY KEY
  (ID)
  USING INDEX CIU.CIUCOURSES_PK
  ENABLE VALIDATE);

ALTER TABLE CIU.CIUCOURSES ADD (
  CONSTRAINT FK_ACADEMICPERIODS 
  FOREIGN KEY (CIUACADEMICPERIOD_ID) 
  REFERENCES CIU.CIUACADEMICPERIODS (ID)
  ENABLE VALIDATE,
  CONSTRAINT FK_COURSESTATES 
  FOREIGN KEY (CIUCOURSESTATE_ID) 
  REFERENCES CIU.CIUCOURSESTATES (ID)
  ENABLE VALIDATE,
  CONSTRAINT FK_LANGUAGE_ID 
  FOREIGN KEY (CIULANGUAGE_ID) 
  REFERENCES CIU.CIULANGUAGES (ID)
  ENABLE VALIDATE,
  CONSTRAINT FK_LEVEL 
  FOREIGN KEY (CIULEVEL_ID) 
  REFERENCES CIU.CIULEVELS (ID)
  ENABLE VALIDATE,
  CONSTRAINT FK_ROOM 
  FOREIGN KEY (CIUROOM_ID) 
  REFERENCES CIU.CIUROOMS (ID)
  ENABLE VALIDATE,
  CONSTRAINT FK_TIMETABLES 
  FOREIGN KEY (CIUTIMETABLE_ID) 
  REFERENCES CIU.CIUTIMETABLES (ID)
  ENABLE VALIDATE,
  CONSTRAINT FK_USERS 
  FOREIGN KEY (CIUUSER_ID) 
  REFERENCES CIU.CIUUSERS (ID)
  ENABLE VALIDATE);

  
---
ALTER TABLE CIU.CIUCOURSESTATES
 DROP PRIMARY KEY CASCADE;

DROP TABLE CIU.CIUCOURSESTATES CASCADE CONSTRAINTS;

CREATE TABLE CIU.CIUCOURSESTATES
(
  ID    NUMBER                                  NOT NULL,
  NAME  VARCHAR2(128 BYTE)
)
TABLESPACE USERS
RESULT_CACHE (MODE DEFAULT)
PCTUSED    0
PCTFREE    10
INITRANS   1
MAXTRANS   255
STORAGE    (
            INITIAL          64K
            NEXT             1M
            MAXSIZE          UNLIMITED
            MINEXTENTS       1
            MAXEXTENTS       UNLIMITED
            PCTINCREASE      0
            BUFFER_POOL      DEFAULT
            FLASH_CACHE      DEFAULT
            CELL_FLASH_CACHE DEFAULT
           )
LOGGING 
NOCOMPRESS 
NOCACHE
NOPARALLEL
MONITORING;


CREATE UNIQUE INDEX CIU.CIUCOURSESTATES_PK ON CIU.CIUCOURSESTATES
(ID)
LOGGING
TABLESPACE USERS
PCTFREE    10
INITRANS   2
MAXTRANS   255
STORAGE    (
            INITIAL          64K
            NEXT             1M
            MAXSIZE          UNLIMITED
            MINEXTENTS       1
            MAXEXTENTS       UNLIMITED
            PCTINCREASE      0
            BUFFER_POOL      DEFAULT
            FLASH_CACHE      DEFAULT
            CELL_FLASH_CACHE DEFAULT
           )
NOPARALLEL;


CREATE OR REPLACE TRIGGER CIU.COURSESTATE_ID_TRIGGER
before insert ON CIU.CIUCOURSESTATES for each row
begin
     select COURSESTATE_ID_SEQ.nextval into :new.id from dual;
end;
/


ALTER TABLE CIU.CIUCOURSESTATES ADD (
  CONSTRAINT CIUCOURSESTATES_PK
  PRIMARY KEY
  (ID)
  USING INDEX CIU.CIUCOURSESTATES_PK
  ENABLE VALIDATE);


----


ALTER TABLE CIU.CIULANGUAGE_CIULEVELS
 DROP PRIMARY KEY CASCADE;

DROP TABLE CIU.CIULANGUAGE_CIULEVELS CASCADE CONSTRAINTS;

CREATE TABLE CIU.CIULANGUAGE_CIULEVELS
(
  ID              NUMBER                        NOT NULL,
  CIULEVEL_ID     NUMBER,
  CIULANGUAGE_ID  NUMBER
)
TABLESPACE USERS
RESULT_CACHE (MODE DEFAULT)
PCTUSED    0
PCTFREE    10
INITRANS   1
MAXTRANS   255
STORAGE    (
            INITIAL          64K
            NEXT             1M
            MAXSIZE          UNLIMITED
            MINEXTENTS       1
            MAXEXTENTS       UNLIMITED
            PCTINCREASE      0
            BUFFER_POOL      DEFAULT
            FLASH_CACHE      DEFAULT
            CELL_FLASH_CACHE DEFAULT
           )
LOGGING 
NOCOMPRESS 
NOCACHE
NOPARALLEL
MONITORING;


CREATE UNIQUE INDEX CIU.CIULANGUAGE_CIULEVELS_PK ON CIU.CIULANGUAGE_CIULEVELS
(ID)
LOGGING
TABLESPACE USERS
PCTFREE    10
INITRANS   2
MAXTRANS   255
STORAGE    (
            INITIAL          64K
            NEXT             1M
            MAXSIZE          UNLIMITED
            MINEXTENTS       1
            MAXEXTENTS       UNLIMITED
            PCTINCREASE      0
            BUFFER_POOL      DEFAULT
            FLASH_CACHE      DEFAULT
            CELL_FLASH_CACHE DEFAULT
           )
NOPARALLEL;


CREATE OR REPLACE TRIGGER CIU.LANGUAGE_LEVELS_ID_TRIGGER
before insert ON CIU.CIULANGUAGE_CIULEVELS for each row
begin
     select LANGUAGE_LEVELS_ID_SEQ.nextval into :new.id from dual;
end;
/


ALTER TABLE CIU.CIULANGUAGE_CIULEVELS ADD (
  CONSTRAINT CIULANGUAGE_CIULEVELS_PK
  PRIMARY KEY
  (ID)
  USING INDEX CIU.CIULANGUAGE_CIULEVELS_PK
  ENABLE VALIDATE);


----


ALTER TABLE CIU.CIULANGUAGES
 DROP PRIMARY KEY CASCADE;

DROP TABLE CIU.CIULANGUAGES CASCADE CONSTRAINTS;

CREATE TABLE CIU.CIULANGUAGES
(
  ID    NUMBER                                  NOT NULL,
  NAME  VARCHAR2(32 BYTE)
)
TABLESPACE USERS
RESULT_CACHE (MODE DEFAULT)
PCTUSED    0
PCTFREE    10
INITRANS   1
MAXTRANS   255
STORAGE    (
            INITIAL          64K
            NEXT             1M
            MAXSIZE          UNLIMITED
            MINEXTENTS       1
            MAXEXTENTS       UNLIMITED
            PCTINCREASE      0
            BUFFER_POOL      DEFAULT
            FLASH_CACHE      DEFAULT
            CELL_FLASH_CACHE DEFAULT
           )
LOGGING 
NOCOMPRESS 
NOCACHE
NOPARALLEL
MONITORING;


CREATE UNIQUE INDEX CIU.CIULANGUAGES_PK ON CIU.CIULANGUAGES
(ID)
LOGGING
TABLESPACE USERS
PCTFREE    10
INITRANS   2
MAXTRANS   255
STORAGE    (
            INITIAL          64K
            NEXT             1M
            MAXSIZE          UNLIMITED
            MINEXTENTS       1
            MAXEXTENTS       UNLIMITED
            PCTINCREASE      0
            BUFFER_POOL      DEFAULT
            FLASH_CACHE      DEFAULT
            CELL_FLASH_CACHE DEFAULT
           )
NOPARALLEL;


CREATE OR REPLACE TRIGGER CIU.LANGUAGE_ID_TRIGGER
before insert ON CIU.CIULANGUAGES for each row
begin
     select LANGUAGE_ID_SEQ.nextval into :new.id from dual;
end;
/


ALTER TABLE CIU.CIULANGUAGES ADD (
  CONSTRAINT CIULANGUAGES_PK
  PRIMARY KEY
  (ID)
  USING INDEX CIU.CIULANGUAGES_PK
  ENABLE VALIDATE);


-----


ALTER TABLE CIU.CIULEVELS
 DROP PRIMARY KEY CASCADE;

DROP TABLE CIU.CIULEVELS CASCADE CONSTRAINTS;

CREATE TABLE CIU.CIULEVELS
(
  ID    NUMBER                                  NOT NULL,
  NAME  VARCHAR2(32 BYTE)
)
TABLESPACE USERS
RESULT_CACHE (MODE DEFAULT)
PCTUSED    0
PCTFREE    10
INITRANS   1
MAXTRANS   255
STORAGE    (
            INITIAL          64K
            NEXT             1M
            MAXSIZE          UNLIMITED
            MINEXTENTS       1
            MAXEXTENTS       UNLIMITED
            PCTINCREASE      0
            BUFFER_POOL      DEFAULT
            FLASH_CACHE      DEFAULT
            CELL_FLASH_CACHE DEFAULT
           )
LOGGING 
NOCOMPRESS 
NOCACHE
NOPARALLEL
MONITORING;


CREATE UNIQUE INDEX CIU.CIULEVELS_PK ON CIU.CIULEVELS
(ID)
LOGGING
TABLESPACE USERS
PCTFREE    10
INITRANS   2
MAXTRANS   255
STORAGE    (
            INITIAL          64K
            NEXT             1M
            MAXSIZE          UNLIMITED
            MINEXTENTS       1
            MAXEXTENTS       UNLIMITED
            PCTINCREASE      0
            BUFFER_POOL      DEFAULT
            FLASH_CACHE      DEFAULT
            CELL_FLASH_CACHE DEFAULT
           )
NOPARALLEL;


CREATE OR REPLACE TRIGGER CIU.LEVEL_ID_TRIGGER
before insert ON CIU.CIULEVELS for each row
begin
     select LEVEL_ID_SEQ.nextval into :new.id from dual;
end;
/


ALTER TABLE CIU.CIULEVELS ADD (
  CONSTRAINT CIULEVELS_PK
  PRIMARY KEY
  (ID)
  USING INDEX CIU.CIULEVELS_PK
  ENABLE VALIDATE);



-----

ALTER TABLE CIU.CIUPARAMETERS
 DROP PRIMARY KEY CASCADE;

DROP TABLE CIU.CIUPARAMETERS CASCADE CONSTRAINTS;

CREATE TABLE CIU.CIUPARAMETERS
(
  ID          NUMBER                            NOT NULL,
  NAME        VARCHAR2(128 BYTE),
  DEFINITION  VARCHAR2(1024 BYTE)
)
TABLESPACE USERS
RESULT_CACHE (MODE DEFAULT)
PCTUSED    0
PCTFREE    10
INITRANS   1
MAXTRANS   255
STORAGE    (
            INITIAL          64K
            NEXT             1M
            MAXSIZE          UNLIMITED
            MINEXTENTS       1
            MAXEXTENTS       UNLIMITED
            PCTINCREASE      0
            BUFFER_POOL      DEFAULT
            FLASH_CACHE      DEFAULT
            CELL_FLASH_CACHE DEFAULT
           )
LOGGING 
NOCOMPRESS 
NOCACHE
NOPARALLEL
MONITORING;


CREATE UNIQUE INDEX CIU.CIUPARAMETERS_PK ON CIU.CIUPARAMETERS
(ID)
LOGGING
TABLESPACE USERS
PCTFREE    10
INITRANS   2
MAXTRANS   255
STORAGE    (
            INITIAL          64K
            NEXT             1M
            MAXSIZE          UNLIMITED
            MINEXTENTS       1
            MAXEXTENTS       UNLIMITED
            PCTINCREASE      0
            BUFFER_POOL      DEFAULT
            FLASH_CACHE      DEFAULT
            CELL_FLASH_CACHE DEFAULT
           )
NOPARALLEL;


CREATE OR REPLACE TRIGGER CIU.PARAMETERS_ID_TRIGGER
before insert ON CIU.CIUPARAMETERS for each row
begin
     select PARAMETERS_ID_SEQ.nextval into :new.id from dual;
end;
/


ALTER TABLE CIU.CIUPARAMETERS ADD (
  CONSTRAINT CIUPARAMETERS_PK
  PRIMARY KEY
  (ID)
  USING INDEX CIU.CIUPARAMETERS_PK
  ENABLE VALIDATE);

----


ALTER TABLE CIU.CIUROOMS
 DROP PRIMARY KEY CASCADE;

DROP TABLE CIU.CIUROOMS CASCADE CONSTRAINTS;

CREATE TABLE CIU.CIUROOMS
(
  ID    NUMBER                                  NOT NULL,
  NAME  VARCHAR2(128 BYTE)
)
TABLESPACE USERS
RESULT_CACHE (MODE DEFAULT)
PCTUSED    0
PCTFREE    10
INITRANS   1
MAXTRANS   255
STORAGE    (
            INITIAL          64K
            NEXT             1M
            MAXSIZE          UNLIMITED
            MINEXTENTS       1
            MAXEXTENTS       UNLIMITED
            PCTINCREASE      0
            BUFFER_POOL      DEFAULT
            FLASH_CACHE      DEFAULT
            CELL_FLASH_CACHE DEFAULT
           )
LOGGING 
NOCOMPRESS 
NOCACHE
NOPARALLEL
MONITORING;


CREATE UNIQUE INDEX CIU.CIUROOMS_PK ON CIU.CIUROOMS
(ID)
LOGGING
TABLESPACE USERS
PCTFREE    10
INITRANS   2
MAXTRANS   255
STORAGE    (
            INITIAL          64K
            NEXT             1M
            MAXSIZE          UNLIMITED
            MINEXTENTS       1
            MAXEXTENTS       UNLIMITED
            PCTINCREASE      0
            BUFFER_POOL      DEFAULT
            FLASH_CACHE      DEFAULT
            CELL_FLASH_CACHE DEFAULT
           )
NOPARALLEL;


CREATE OR REPLACE TRIGGER CIU.ROOM_ID_TRIGGER
before insert ON CIU.CIUROOMS for each row
begin
     select ROOM_ID_SEQ.nextval into :new.id from dual;
end;
/


ALTER TABLE CIU.CIUROOMS ADD (
  CONSTRAINT CIUROOMS_PK
  PRIMARY KEY
  (ID)
  USING INDEX CIU.CIUROOMS_PK
  ENABLE VALIDATE);


----

ALTER TABLE CIU.CIUSTUDENTTYPES
 DROP PRIMARY KEY CASCADE;

DROP TABLE CIU.CIUSTUDENTTYPES CASCADE CONSTRAINTS;

CREATE TABLE CIU.CIUSTUDENTTYPES
(
  ID    NUMBER                                  NOT NULL,
  NAME  VARCHAR2(128 BYTE)
)
TABLESPACE USERS
RESULT_CACHE (MODE DEFAULT)
PCTUSED    0
PCTFREE    10
INITRANS   1
MAXTRANS   255
STORAGE    (
            INITIAL          64K
            NEXT             1M
            MAXSIZE          UNLIMITED
            MINEXTENTS       1
            MAXEXTENTS       UNLIMITED
            PCTINCREASE      0
            BUFFER_POOL      DEFAULT
            FLASH_CACHE      DEFAULT
            CELL_FLASH_CACHE DEFAULT
           )
LOGGING 
NOCOMPRESS 
NOCACHE
NOPARALLEL
MONITORING;


CREATE UNIQUE INDEX CIU.CIUSTUDENTTYPE_PK ON CIU.CIUSTUDENTTYPES
(ID)
LOGGING
TABLESPACE USERS
PCTFREE    10
INITRANS   2
MAXTRANS   255
STORAGE    (
            INITIAL          64K
            NEXT             1M
            MAXSIZE          UNLIMITED
            MINEXTENTS       1
            MAXEXTENTS       UNLIMITED
            PCTINCREASE      0
            BUFFER_POOL      DEFAULT
            FLASH_CACHE      DEFAULT
            CELL_FLASH_CACHE DEFAULT
           )
NOPARALLEL;


CREATE OR REPLACE TRIGGER CIU.STUDENTTYPE_ID_TRIGGER
before insert ON CIU.CIUSTUDENTTYPES for each row
begin
     select STUDENTTYPE_ID_SEQ.nextval into :new.id from dual;
end;
/


ALTER TABLE CIU.CIUSTUDENTTYPES ADD (
  CONSTRAINT CIUSTUDENTTYPES_PK
  PRIMARY KEY
  (ID)
  USING INDEX CIU.CIUSTUDENTTYPE_PK
  ENABLE VALIDATE);


----

ALTER TABLE CIU.CIUTEACHERTYPES
 DROP PRIMARY KEY CASCADE;

DROP TABLE CIU.CIUTEACHERTYPES CASCADE CONSTRAINTS;

CREATE TABLE CIU.CIUTEACHERTYPES
(
  ID    NUMBER                                  NOT NULL,
  NAME  VARCHAR2(128 BYTE)
)
TABLESPACE USERS
RESULT_CACHE (MODE DEFAULT)
PCTUSED    0
PCTFREE    10
INITRANS   1
MAXTRANS   255
STORAGE    (
            INITIAL          64K
            NEXT             1M
            MAXSIZE          UNLIMITED
            MINEXTENTS       1
            MAXEXTENTS       UNLIMITED
            PCTINCREASE      0
            BUFFER_POOL      DEFAULT
            FLASH_CACHE      DEFAULT
            CELL_FLASH_CACHE DEFAULT
           )
LOGGING 
NOCOMPRESS 
NOCACHE
NOPARALLEL
MONITORING;


CREATE UNIQUE INDEX CIU.CIUTEACHERTYPE_PK ON CIU.CIUTEACHERTYPES
(ID)
LOGGING
TABLESPACE USERS
PCTFREE    10
INITRANS   2
MAXTRANS   255
STORAGE    (
            INITIAL          64K
            NEXT             1M
            MAXSIZE          UNLIMITED
            MINEXTENTS       1
            MAXEXTENTS       UNLIMITED
            PCTINCREASE      0
            BUFFER_POOL      DEFAULT
            FLASH_CACHE      DEFAULT
            CELL_FLASH_CACHE DEFAULT
           )
NOPARALLEL;


CREATE OR REPLACE TRIGGER CIU.TEACHERTYPE_ID_TRIGGER
before insert ON CIU.CIUTEACHERTYPES for each row
begin
     select TEACHERTYPE_ID_SEQ.nextval into :new.id from dual;
end;
/


ALTER TABLE CIU.CIUTEACHERTYPES ADD (
  CONSTRAINT CIUTEACHERTYPES_PK
  PRIMARY KEY
  (ID)
  USING INDEX CIU.CIUTEACHERTYPE_PK
  ENABLE VALIDATE);


-----

ALTER TABLE CIU.CIUTIMETABLES
 DROP PRIMARY KEY CASCADE;

DROP TABLE CIU.CIUTIMETABLES CASCADE CONSTRAINTS;

CREATE TABLE CIU.CIUTIMETABLES
(
  ID    NUMBER                                  NOT NULL,
  NAME  VARCHAR2(128 BYTE)
)
TABLESPACE USERS
RESULT_CACHE (MODE DEFAULT)
PCTUSED    0
PCTFREE    10
INITRANS   1
MAXTRANS   255
STORAGE    (
            INITIAL          64K
            NEXT             1M
            MAXSIZE          UNLIMITED
            MINEXTENTS       1
            MAXEXTENTS       UNLIMITED
            PCTINCREASE      0
            BUFFER_POOL      DEFAULT
            FLASH_CACHE      DEFAULT
            CELL_FLASH_CACHE DEFAULT
           )
LOGGING 
NOCOMPRESS 
NOCACHE
NOPARALLEL
MONITORING;


CREATE UNIQUE INDEX CIU.CIUTIMETABLES_PK ON CIU.CIUTIMETABLES
(ID)
LOGGING
TABLESPACE USERS
PCTFREE    10
INITRANS   2
MAXTRANS   255
STORAGE    (
            INITIAL          64K
            NEXT             1M
            MAXSIZE          UNLIMITED
            MINEXTENTS       1
            MAXEXTENTS       UNLIMITED
            PCTINCREASE      0
            BUFFER_POOL      DEFAULT
            FLASH_CACHE      DEFAULT
            CELL_FLASH_CACHE DEFAULT
           )
NOPARALLEL;


CREATE OR REPLACE TRIGGER CIU.TIMETABLE_ID_TRIGGER
before insert ON CIU.CIUTIMETABLES for each row
begin
     select TIMETABLE_ID_SEQ.nextval into :new.id from dual;
end;
/


ALTER TABLE CIU.CIUTIMETABLES ADD (
  CONSTRAINT CIUTIMETABLES_PK
  PRIMARY KEY
  (ID)
  USING INDEX CIU.CIUTIMETABLES_PK
  ENABLE VALIDATE);



-----


ALTER TABLE CIU.CIUUSERS
 DROP PRIMARY KEY CASCADE;

DROP TABLE CIU.CIUUSERS CASCADE CONSTRAINTS;

CREATE TABLE CIU.CIUUSERS
(
  ID                      NUMBER                NOT NULL,
  NAME                    VARCHAR2(128 BYTE),
  PASSWORD                VARCHAR2(256 BYTE),
  FIRST_NAMES             VARCHAR2(128 BYTE),
  LAST_NAMES              VARCHAR2(128 BYTE),
  DOCUMENT_TYPE           VARCHAR2(2 BYTE),
  DOCUMENT                VARCHAR2(20 BYTE),
  EXPEDITION_DATE         DATE,
  BIRTHDAY                DATE,
  ADDRESS                 VARCHAR2(256 BYTE),
  TELEPHONE               VARCHAR2(32 BYTE),
  EMAIL                   VARCHAR2(256 BYTE),
  ACADEMIC_LEVEL          VARCHAR2(64 BYTE),
  OCCUPATION              VARCHAR2(64 BYTE),
  OCCUPATION_DESCRIPTION  VARCHAR2(256 BYTE),
  CIUUSERSTATE_ID         NUMBER,
  CIUUSERTYPE_ID          NUMBER,
  CONTACT_NAME            VARCHAR2(256 BYTE),
  CONTACT_TELEPHONE       VARCHAR2(32 BYTE),
  CREATED                 DATE,
  MODIFIED                DATE,
  ISACTIVE                VARCHAR2(1 BYTE),
  CIUSTUDENTTYPE_ID       NUMBER,
  CIUTEACHERTYPE_ID       NUMBER
)
TABLESPACE USERS
RESULT_CACHE (MODE DEFAULT)
PCTUSED    0
PCTFREE    10
INITRANS   1
MAXTRANS   255
STORAGE    (
            INITIAL          64K
            NEXT             1M
            MAXSIZE          UNLIMITED
            MINEXTENTS       1
            MAXEXTENTS       UNLIMITED
            PCTINCREASE      0
            BUFFER_POOL      DEFAULT
            FLASH_CACHE      DEFAULT
            CELL_FLASH_CACHE DEFAULT
           )
LOGGING 
NOCOMPRESS 
NOCACHE
NOPARALLEL
MONITORING;


CREATE UNIQUE INDEX CIU.CIUUSERS_PK ON CIU.CIUUSERS
(ID)
LOGGING
TABLESPACE USERS
PCTFREE    10
INITRANS   2
MAXTRANS   255
STORAGE    (
            INITIAL          64K
            NEXT             1M
            MAXSIZE          UNLIMITED
            MINEXTENTS       1
            MAXEXTENTS       UNLIMITED
            PCTINCREASE      0
            BUFFER_POOL      DEFAULT
            FLASH_CACHE      DEFAULT
            CELL_FLASH_CACHE DEFAULT
           )
NOPARALLEL;


CREATE OR REPLACE TRIGGER CIU.ciu_user_id_trigger
   before insert ON CIU.CIUUSERS for each row
begin
     select user_id_seq.nextval into :new.id from dual;
   end;
/


ALTER TABLE CIU.CIUUSERS ADD (
  CONSTRAINT CIUUSERS_PK
  PRIMARY KEY
  (ID)
  USING INDEX CIU.CIUUSERS_PK
  ENABLE VALIDATE);

ALTER TABLE CIU.CIUUSERS ADD (
  CONSTRAINT FK_STUDENTTYPES 
  FOREIGN KEY (CIUSTUDENTTYPE_ID) 
  REFERENCES CIU.CIUSTUDENTTYPES (ID)
  ENABLE VALIDATE,
  CONSTRAINT FK_TEACHERTYPES 
  FOREIGN KEY (CIUTEACHERTYPE_ID) 
  REFERENCES CIU.CIUTEACHERTYPES (ID)
  ENABLE VALIDATE,
  CONSTRAINT FK_USER 
  FOREIGN KEY (CIUUSERSTATE_ID) 
  REFERENCES CIU.CIUUSERSTATES (ID)
  ENABLE VALIDATE,
  CONSTRAINT FK_USERTYPE 
  FOREIGN KEY (CIUUSERTYPE_ID) 
  REFERENCES CIU.CIUUSERTYPES (ID)
  ENABLE VALIDATE);



----


ALTER TABLE CIU.CIUUSERSTATES
 DROP PRIMARY KEY CASCADE;

DROP TABLE CIU.CIUUSERSTATES CASCADE CONSTRAINTS;

CREATE TABLE CIU.CIUUSERSTATES
(
  ID    NUMBER                                  NOT NULL,
  NAME  VARCHAR2(128 BYTE)
)
TABLESPACE USERS
RESULT_CACHE (MODE DEFAULT)
PCTUSED    0
PCTFREE    10
INITRANS   1
MAXTRANS   255
STORAGE    (
            INITIAL          64K
            NEXT             1M
            MAXSIZE          UNLIMITED
            MINEXTENTS       1
            MAXEXTENTS       UNLIMITED
            PCTINCREASE      0
            BUFFER_POOL      DEFAULT
            FLASH_CACHE      DEFAULT
            CELL_FLASH_CACHE DEFAULT
           )
LOGGING 
NOCOMPRESS 
NOCACHE
NOPARALLEL
MONITORING;


CREATE UNIQUE INDEX CIU.CIUUSERSTATES_PK ON CIU.CIUUSERSTATES
(ID)
LOGGING
TABLESPACE USERS
PCTFREE    10
INITRANS   2
MAXTRANS   255
STORAGE    (
            INITIAL          64K
            NEXT             1M
            MAXSIZE          UNLIMITED
            MINEXTENTS       1
            MAXEXTENTS       UNLIMITED
            PCTINCREASE      0
            BUFFER_POOL      DEFAULT
            FLASH_CACHE      DEFAULT
            CELL_FLASH_CACHE DEFAULT
           )
NOPARALLEL;


CREATE OR REPLACE TRIGGER CIU.USERSTATE_ID_TRIGGER
before insert ON CIU.CIUUSERSTATES for each row
begin
     select USERSTATE_ID_SEQ.nextval into :new.id from dual;
end;
/


ALTER TABLE CIU.CIUUSERSTATES ADD (
  CONSTRAINT CIUUSERSTATES_PK
  PRIMARY KEY
  (ID)
  USING INDEX CIU.CIUUSERSTATES_PK
  ENABLE VALIDATE);



-----


ALTER TABLE CIU.CIUUSERTYPES
 DROP PRIMARY KEY CASCADE;

DROP TABLE CIU.CIUUSERTYPES CASCADE CONSTRAINTS;

CREATE TABLE CIU.CIUUSERTYPES
(
  ID    NUMBER                                  NOT NULL,
  NAME  VARCHAR2(128 BYTE)
)
TABLESPACE USERS
RESULT_CACHE (MODE DEFAULT)
PCTUSED    0
PCTFREE    10
INITRANS   1
MAXTRANS   255
STORAGE    (
            INITIAL          64K
            NEXT             1M
            MAXSIZE          UNLIMITED
            MINEXTENTS       1
            MAXEXTENTS       UNLIMITED
            PCTINCREASE      0
            BUFFER_POOL      DEFAULT
            FLASH_CACHE      DEFAULT
            CELL_FLASH_CACHE DEFAULT
           )
LOGGING 
NOCOMPRESS 
NOCACHE
NOPARALLEL
MONITORING;


CREATE UNIQUE INDEX CIU.CIUUSERTYPES_PK ON CIU.CIUUSERTYPES
(ID)
LOGGING
TABLESPACE USERS
PCTFREE    10
INITRANS   2
MAXTRANS   255
STORAGE    (
            INITIAL          64K
            NEXT             1M
            MAXSIZE          UNLIMITED
            MINEXTENTS       1
            MAXEXTENTS       UNLIMITED
            PCTINCREASE      0
            BUFFER_POOL      DEFAULT
            FLASH_CACHE      DEFAULT
            CELL_FLASH_CACHE DEFAULT
           )
NOPARALLEL;


CREATE OR REPLACE TRIGGER CIU.USERTYPE_ID_TRIGGER
before insert ON CIU.CIUUSERTYPES for each row
begin
     select USERTYPE_ID_SEQ.nextval into :new.id from dual;
end;
/


ALTER TABLE CIU.CIUUSERTYPES ADD (
  CONSTRAINT CIUUSERTYPES_PK
  PRIMARY KEY
  (ID)
  USING INDEX CIU.CIUUSERTYPES_PK
  ENABLE VALIDATE);
  
  
  
  

  
  
  
  
 